﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 确认注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            var name = this.textBox1.Text;
            var pwd = this.textBox2.Text;
            var pwdTry = this.textBox3.Text;
            var conString = string.Format("select*from Load");
            var con = DbHelper.GetDataTable(conString);
            bool hasName = !string.IsNullOrEmpty(name);
            bool hasPwd = !string.IsNullOrEmpty(pwd);
            bool equal = pwd == pwdTry;

            if (hasName && hasPwd && equal)
            {
                var register = string.Format("insert into Load values('{0}','{1}')",name,pwd);
                var res = DbHelper.AddOrDeleteOrEdittOrSave(register);
                MessageBox.Show("注册成功");
                this.Close();
            }
            else 
            {
                MessageBox.Show("注册失败");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
